package com.qf.homework2.servlet.impl;

import com.qf.homework2.dao.UserDao;
import com.qf.homework2.entity.User;
import com.qf.homework2.servlet.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class UserServiceImpl implements UserService {

    @Autowired
    private UserDao userDao;

    @Override
    public boolean usernameExist(String username) {

        List<User> allUsers = userDao.getAllUsers();
        for (User allUser : allUsers) {
            if (allUser.getUsername().equals(username)){
                return true;
            }
        }
        return false;
    }
}
